package com.qijia.common.dao.impl;

import java.lang.reflect.Method;

import com.qijia.common.utils.ObjectUtils;

public class DbExceptionUtils {

	/**
	 * 格式化异常参数输出
	 * 
	 * @param obj
	 * @return
	 */
	public static String buildMessage(Object obj) {
		if (obj == null)
			return "obj is null";
		StringBuilder builder = new StringBuilder();
		for (Method method : obj.getClass().getDeclaredMethods()) {
			if (method.getName().indexOf("get") == 0) {
				try {
					builder.append(method.getName() + "["
							+ ObjectUtils.invokeMethod(obj, method.getName())
							+ "]");
				} catch (Exception e) {
					e.printStackTrace();
					continue;
				}
			}
		}
		return builder.toString();
	}
}
